package com.chris.design.pattern.samples.prototype;

import com.chris.design.pattern.samples.prototype.AbstractPrototype;
import com.chris.design.pattern.samples.prototype.ConcretePrototype1;
import com.chris.design.pattern.samples.prototype.ConcretePrototype2;

/**
 * 原型模式（其实也是Java中深浅copy问题）
 */
public class PrototypeAppMain {

    public static void main(String[] args) {
        AbstractPrototype prototype = new ConcretePrototype1(ConcretePrototype1.class.getSimpleName());
        AbstractPrototype pt1 = (AbstractPrototype) prototype.clone();
        System.out.println("prototype==" + prototype);
        System.out.println("pt1==" + pt1);
        System.out.println("=============================");

        AbstractPrototype prototype2 = new ConcretePrototype2(ConcretePrototype2.class.getSimpleName());
        AbstractPrototype pt2 = (AbstractPrototype) prototype2.clone();
        System.out.println("prototype2==" + prototype2);
        System.out.println("pt2==" + pt2);
    }

}
